<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="base/layout.html">


    <!-- start: Content -->
    <div layout:fragment="content" class="main ">

        <div class="row">
            <div class="col-lg-12">
                <ol class="breadcrumb">
                    <li><i class="fa fa-home"></i><a href="index.html">主页</a></li>

                    <li><i class="fa fa-indent"></i>添加用户信息</li>
                </ol>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h2><i class="fa fa-indent red"></i><strong>添加用户信息</strong></h2>
                    </div>
                    <div class="panel-body">
                        <form id="modularForm"  method="post" enctype="multipart/form-data" class="form-horizontal ">

                            <div class="form-group">
                                <label class="col-md-3 control-label" for="select">承办部门</label>
                                <div class="col-md-2">
                                    <select id="selectDepartment" name="departmentid" class="form-control" size="1" type="isNotSelectNull">

                                    </select>
                                    <span class="help-block">请选择承办部门</span>
                                </div>
                            </div>



                            <div class="form-group">
                                <label class="col-md-3 control-label" for="text-input">账户名</label>
                                <div class="col-md-2">
                                    <input type="text"  name="name" class="form-control" placeholder="账户名" required>
                                    <span class="help-block">请输入账户名</span>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label" for="text-input">密码</label>
                                <div class="col-md-2">
                                    <input type="password"  name="password" class="form-control" required>
                                    <span class="help-block">请输入密码</span>
                                </div>
                            </div>




                            <br>

                    </div>
                    <div class="panel-footer">
                        <button id="submitBtn" type="submit" class="btn btn-sm btn-success"><i class="fa fa-dot-circle-o"></i> 提交</button>
                        <button type="reset" class="btn btn-sm btn-danger"><i class="fa fa-ban"></i>重置</button>
                    </div>
                    </form>
                </div>
            </div>


        </div><!--/.row-->


        <script>

            $(document).ready(function() {

                //加载承办部门
                initDepartment();


            })




            //加载承办部门
            function initDepartment(){
                $("#selectDepartment").append("<option value=-1>请选择</option>");
                $.ajax({
                    url:'../department/selectDepartmentInfo',
                    type:'get',
                    dataType:'json',
                    data:{},
                    success:function (data) {
                        for(var i in data){
                            $("#selectDepartment").append("<option value="+data[i].id+">"+data[i].department+"</option>");
                        }
                    }
                })

            }



            $("#modularForm").validate({

                submitHandler: function(form)
                {

                    $('#modularForm').ajaxSubmit(      //ajax方式提交表单
                        {
                            url: 'userInfoAdd',
                            type: 'post',
                            success: function (data) {
                                layer.msg("添加成功");
                                setTimeout(function () {
                                    window.location = ("queryUserInfo")
                                },1500);
                            }
                            //clearForm: false,//禁止清楚表单
                            //resetForm: false //禁止重置表单
                        });





                }
            })









        </script>

    </div>




    <!-- end: Content -->

